package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.YYWeddingCelebration;

/**
 * 
 * @author 
 *
 */
@DAO
public interface YYWeddingCelebrationDAO{
	
	@SQL("SELECT * FROM YYWeddingCelebration WHERE deleteFlag=1 #if(:t.productName!=''){ AND productName LIKE '%##(:t.productName)%' } ORDER BY stickAt DESC,updateAt DESC LIMIT :t.start,:t.length ")
    List<YYWeddingCelebration> query(@SQLParam("t") YYWeddingCelebration yYWeddingCelebration);
	
	@SQL("SELECT count(1) FROM YYWeddingCelebration WHERE deleteFlag=1 #if(:t.productName!=''){ AND productName LIKE '%##(:t.productName)%' } ")
    int querysize(@SQLParam("t") YYWeddingCelebration yYWeddingCelebration);
    
    @SQL("SELECT * FROM YYWeddingCelebration WHERE id=:1")
    YYWeddingCelebration queryById(int id);
    
    @SQL("INSERT INTO YYWeddingCelebration (img,productName,sellerName,price,tel,area,address,type,state,descs,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.img,:t.productName,:t.sellerName,:t.price,:t.tel,:t.area,:t.address,:t.type,:t.state,:t.descs,1,now(),:t.createUser,now(),:t.updateUser)")
	void create(@SQLParam("t") YYWeddingCelebration yYWeddingCelebration);
	
	@SQL("UPDATE YYWeddingCelebration SET img=:t.img,type=:t.type,productName=:t.productName,sellerName=:t.sellerName,price=:t.price,tel=:t.tel,area=:t.area,address=:t.address,descs=:t.descs,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
	void update(@SQLParam("t") YYWeddingCelebration yYWeddingCelebration);
    
    @SQL("UPDATE YYWeddingCelebration SET deleteFlag=0,updateAt=now() WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE YYWeddingCelebration SET state=:2,updateAt=now() WHERE id=:1 ")
    void updateStateById(int id,int state);
    
    @SQL("UPDATE YYWeddingCelebration SET stickAt=NOW() WHERE id=:1")
	void stick(int id);
}